package com.cy.bfzcommons.web.util;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletUtil {
    //获取Servlet
    public static ServletRequestAttributes getRequestAttribures(){
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes ();
        return (ServletRequestAttributes) requestAttributes;
    }
    //获取Requset
    public static HttpServletRequest getRequest(){
        return getRequestAttribures ().getRequest ();
    }
    //获取Response
    public static HttpServletResponse getResponse(){
        return getRequestAttribures ().getResponse ();
    }

}
